import Vue from 'vue'
import VueRouter, { RouteConfig } from 'vue-router'

Vue.use(VueRouter)

const routes: Array<RouteConfig> = [
  // {
  //   path: '/',
  //   redirect: '/user/login'
  // },
  {
    path: '/user/login',
    name: 'Login',
    component: () => import('@/views/user/UserLogin.vue')
  },
  {
    path: '/user',
    component: () => import('@/views/user/UserLayout.vue'),
    redirect: '/user/orders',
    children: [
      {
        path: 'orders',
        name: 'UserOrders',
        component: () => import('@/views/user/UserOrders.vue'),
        meta: { title: '我的订单', requiresAuth: true }
      },
      {
        path: 'recycletype',
        name: 'UserRecycleType',
        component: () => import('@/views/user/UserRecycleType.vue'),
        meta: { title: '废品回收', requiresAuth: true }
      },
      {
        path: 'profile',
        name: 'UserProfile',
        component: () => import('@/views/user/UserProfile.vue'),
        meta: { title: '个人资料', requiresAuth: true }
      },
      {
        path: 'chat',
        name: 'UserChat',
        component: () => import('@/views/user/UserChat.vue'),
        meta: { title: '在线交流', requiresAuth: true }
      },
      {
        path: 'map',
        name: 'UserMap',
        component: () => import('@/views/user/MapIndex.vue'),
        meta: { title: '地图导航', requiresAuth: true }
      },
      {
        path: 'place-order',
        name: 'PlaceOrder',
        component: () => import('@/views/user/PlaceOrder.vue'),
        meta: {
          title: '下单'
        }
      }

    ]
  },
  {
    path: '/platform/login',
    name: 'PlatformLogin',
    component: () => import('@/views/platform/AccountLogin.vue')
  },
  {
    path: '/platform',
    component: () => import('@/views/platform/PlatformLayout.vue'),
    redirect: '/platform/orders',
    children: [
      {
        path: 'announcement',
        name: 'AnnouncementManagement',
        component: () => import('@/views/platform/AnnouncementManagement.vue'),
        meta: { title: '公告管理', requiresAdminAuth: true }
      },
      {
        path: 'orders',
        name: 'AllOrders',
        component: () => import('@/views/platform/AllOrders.vue'),
        meta: {
          title: '所有订单查询',
          requireAuth: true
        }
      },
      {
        path: 'permission',
        name: 'Permission',
        component: () => import('@/components/Permission.vue'),
        meta: { title: '权限管理', requiresAdminAuth: true }
      },
      {
        path: 'stations',
        name: 'StationManagement',
        component: () => import('@/views/platform/StationManagement.vue'),
        meta: { title: '站点管理', requiresAdminAuth: true }
      }, 
      {
        path: 'material',
        name: 'MaterialTypeManagement',
        component: () => import('@/views/platform/MaterialTypeManagement.vue'),
        meta: { title: '物料管理', requiresAuth: true }
      },
      {
        path: 'PlatFormChatNetty',
        name: 'PlatFormChatNetty',
        component: () => import('@/views/platform/PlatFormChatNetty.vue'),
        meta: { title: '聊天', requiresAuth: true }
      },
      {
        path: 'UserChatNetty',
        name: 'UserChatNetty',
        component: () => import('@/views/user/UserChatNetty.vue'),
        meta: { title: '聊天', requiresAuth: true }
      },
      {
        path: 'sale',
        name: 'SalesReport',
        component: () => import('@/views/platform/SalesReport.vue'),
        meta: { title: '聊天', requiresAuth: true }
      }

    ]
  },
  {
    path: '/service/chat',
    name: 'ServiceChat',
    component: () => import('@/views/platform/ServiceChat.vue'),
    meta: { requiresAdminAuth: true }
  },
  {
    path: '/station',
    component: () => import('@/views/station/StationLayout.vue'),
    redirect: '/station/management',
    children: [
      {
        path: 'management',
        name: 'StationManagement',
        component: () => import('@/views/station/StationManagement.vue'),
        meta: { title: '站点概览', requiresAuth: true }
      },
      {
        path: 'announcement',
        name: 'AnnouncementNotification',
        component: () => import('@/views/station/AnnouncementNotification.vue'),
        meta: { title: '公告查看', requiresAuth: true }
      },{
        path: 'pricing',
        name: 'StationPricing',
        component: () => import('@/views/station/WastePricing.vue'),
        meta: { title: '废品定价', requiresAuth: true }
      },
      {
        path: 'orders',
        name: 'StationOrders',
        component: () => import('@/views/station/StationOrders.vue'),
        meta: { title: '订单管理', requiresAuth: true }
      }
    ]
  }
]

const router = new VueRouter({
  routes
})

export default router
